home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 361 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.4 KB  |  33 lines

  1. Newsgroups: comp.std.c
  2. Path: phcoms4.seri.philips.nl!panther!baynes
  3. From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes)
  4. Subject: Re: random floating point!
  5. Sender: news@ukpsshp1.serigate.philips.nl (account for localnews)
  6. Message-ID: <Dn817B.90v@ukpsshp1.serigate.philips.nl>
  7. Date: Fri, 23 Feb 1996 09:04:23 GMT
  8. References: <4ghuql$80h@bignews.shef.ac.uk>
  9. Organization: Philips Semiconductors, Southampton, UK
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Daniel Williamson (D.G.Williamson@shef.ac.uk) wrote:
  13. : Does anybody know how to generate a random floating point number. I am using 
  14. : top speed c, for the work and the rand() function ad defined in the ansi 
  15. : standard only goes up to 32767. I suppose I could multiply it, but I'm looking 
  16. : for a more elegant solution to give me the full range of +ve and -ve values.
  17. : Thanks for any help you can offer.
  18.  
  19. To be precise ANSI rand() goes up to RAND_MAX which must be at least 32767.
  20. It can be more.
  21.  
  22. Discussion of algorithms for floating point random numbers is outside the
  23. range of this group. I would also suggest that you read up on distributions
  24. in a book on probability and decide what distribution you want before you
  25. ask the question.
  26.  
  27.  
  28. --
  29. Stephen Baynes                              baynes@mulsoc2.serigate.philips.nl
  30. Philips Semiconductors Ltd
  31. Southampton                                 My views are my own.
  32. United Kingdom
  33.